/*
 * This class is used for fade in / out animation.
 * We will change alpha of Paint from fromAlpha to toAlpha
 * */
package com.xxxx.game;

import android.graphics.Paint;
import android.util.Log;

public class FadeAnimation implements IPaintAnimation {

	private int mFromAlpha;
	private int mToAlpha;
	private int mStepCount;
	private int mCurStepCount;
	
	public FadeAnimation()
	{
		this.mFromAlpha = 0;
		this.mToAlpha = 0;
		this.mStepCount = 0;
		this.mCurStepCount = 0;
	}
	public FadeAnimation(int iFromAlpha, int iToAlpha, int iStepCount)
	{
		this.mFromAlpha = iFromAlpha;
		this.mToAlpha = iToAlpha;
		this.mStepCount = iStepCount;
		this.mCurStepCount = 0;
		
	}
	
	@Override
	public Paint update(Paint paint)
	{
		this.mCurStepCount ++;
		this.LinearInterpolation();
		Paint paintObj = new Paint();
		Log.i("FadeAnimation", " " + this.mToAlpha);
		paintObj.setAlpha(this.mToAlpha);
		return paintObj;
	}
	
	private void LinearInterpolation()
	{
		this.mToAlpha = this.mFromAlpha - ((this.mFromAlpha - this.mToAlpha) / this.mStepCount) * this.mCurStepCount;
	}

}
